﻿#pragma once
//
//  mem_item.hpp
//  JanMalloc
//
//  Created by janhit on 2022/4/16.
//

#ifndef __mem_item_h__
#define __mem_item_h__

#include "TypesDef.hpp"
#include <thread>
#include <time.h>


namespace MMFAlloc{


class MemoryItem final
{

    friend struct Allocator;
    
private:
    
    //所属线程
    const std::thread::id& mThradId;
    
    //本块大小
    u32 mSize;
    
    //地址
    void* mBuff;
    
    //创建时间
    time_t mCreateTime;
    
    //上一次访问时间
    time_t mLastAccessTime;
    
public:
    
    MemoryItem(unsigned int size, const std::thread::id& thdId);
    
    u32 Size();
    time_t CreateTime();
    time_t LastAccessTime();
    void OnAccess();
    void* Address();
    const std::thread::id& ThreadId();
};



}





#endif /* mem_item_h */
